package com.wuneng.ircontrol;

import android.os.Environment;

import com.wuneng.ircontrol.myUtil.common.CrashHandler;
import com.wuneng.commonlibrary.base.BaseApplication;
import com.clj.fastble.BleManager;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

import java.io.File;

public class MyApp extends BaseApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        CrashHandler.getInstance().init(getApplicationContext());
//        BleManager.getInstance().init(this);
//        BleManager.getInstance().enableLog(true).setReConnectCount(1, 5000).setOperateTimeout(5000);

        initImageloader();
    }

    private void initImageloader() {
        // 初始化ImageLoader
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).threadPoolSize(Runtime.getRuntime().availableProcessors() * 2)
                .threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().tasksProcessingOrder(QueueProcessingType.LIFO).denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024).memoryCacheSizePercentage(13).diskCacheSize(200 * 1024 * 1024)
                .diskCache(new UnlimitedDiskCache(new File(Environment.getExternalStorageDirectory() + "/" + R.string.app_name + "/imageCache/"))).tasksProcessingOrder(QueueProcessingType.LIFO).build();
        ImageLoader.getInstance().init(config);

    }

    @Override
    protected boolean toggleCrashHelper() {
        return false;
    }

    @Override
    protected boolean toggleCustomFonts() {
        return false;
    }

    @Override
    protected boolean toggleXLogDebug() {
        return false;
    }

    @Override
    protected String fontPath() {
        return null;
    }
}
